{template Public:Page:header}
<form id="Form">
<div class="container">
  <div class="row">
  
    {template Member:Index:sidebar}
    
    <div class="col-lg-10 well-col-pl-30">
      <div class="row">
           <div class="well">
           <h3>我的位置</h3>
           <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.3"></script>
           <div class="alert alert-info fade in">
                <button data-dismiss="alert" class="close">
                    ×
                </button>
                <i class="fa-fw fa fa-info"></i>
                <strong>提示</strong> 双击地图自动保存您的位置
            </div>
                     
 			<div id="SetMap" style="height:600px"> 
    		</div>
            
            <input type="hidden" name="longitude" id="MapLongitude" value="{if $member['longitude']}{echo $member['longitude']}{/if}"/>
    
            <input type="hidden" name="latitude" id="MapLatitude" value="{if $member['latitude']}{echo $member['latitude']}{/if}"/>
            
           </div>
    </div>
  </div>
</div>
</div>
</form>

<script type="text/javascript">

var zoom=12;
var long=108.318421;
var lat=22.800617;

var Longitude=$('#MapLongitude').val();
		
var Latitude=$('#MapLatitude').val();
		
	
if(Longitude){
	long=parseFloat(Longitude);
}

if(Latitude){
	lat=parseFloat(Latitude);
}

var map = new BMap.Map("SetMap"); 
var point = new BMap.Point(long,lat);

map.centerAndZoom(point,zoom);

map.addControl(new BMap.NavigationControl()); 

map.enableScrollWheelZoom();


var marker = new BMap.Marker(point);        // 创建标注  
map.addOverlay(marker); 

if(!Longitude){
	
	  function myFun(result){
		  var cityName = result.name;
		  map.setCenter(cityName);
	  }
	  var myCity = new BMap.LocalCity();
	  myCity.get(myFun);

}


var gc = new BMap.Geocoder();    

map.addEventListener("ondblclick", function(e){  
	
	  var pt = e.point;
	 	
	  map.removeOverlay(marker);  

      $('#MapLongitude').val(e.point.lng);
	   
	  $('#MapLatitude').val(e.point.lat);  
	  
	  point = new BMap.Point(e.point.lng,e.point.lat);
	  marker = new BMap.Marker(point);        
      map.addOverlay(marker); 
	
	  $.post('/post/member/location',$("#Form").serialize(), function(json) {

			bootbox.alert({
				 message: json.message
			});

			return true;
		
	  }, 'json');

}); 
	 
</script>		 
                 
{template Public:Page:footer}